package cn.yyt.yytravel.scene.service;

import cn.yyt.yytravel.scene.mapper.AreaMapper;
import cn.yyt.yytravel.scene.pojo.Area1;
import cn.yyt.yytravel.scene.pojo.AreaQuery;
import cn.yyt.yytravel.scene.pojo.AreaSaveParam;
import cn.yyt.yytravel.scene.pojo.AreaVO;
import cn.yyt.yytravel.user.pojo.entity.User;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AreaServiceImpl implements AreaService{

@Autowired
    private AreaMapper areaMapper;

    @Override
    public List<AreaVO> selectArea(AreaQuery areaQuery) {
       List<AreaVO> list =areaMapper.selectArea(areaQuery);
        return list;
    }

    @Override
    public List<AreaVO> selectAreaById(Integer id) {
        List<AreaVO> list =areaMapper.selectAreaById(id);
        return list;
    }

    @Override
    public void saveArea(AreaSaveParam areaSaveParam) {
        Area1 area1 = new Area1();
        BeanUtils.copyProperties(areaSaveParam,area1);
        if (area1.getId()==null){
            areaMapper.insert(area1);
        }else {
            areaMapper.update(area1);
        }

    }

    @Override
    public void deleteArea(Long userId) {
        areaMapper.deleteById(userId);
    }


}
